﻿package view.popup
{
    import com.core.*;
    import com.sh.game.global.*;
    import flash.events.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import view.mornExtends.*;
    import view.popup.ui.*;
    import view.uilt.*;

    public class DBQBFBResultCtrl extends DBQBUI implements IDialogUI
    {
        private var _rews:String = "207800/207801/207802/207803/207804&207797/207798/207798/207799/207799";
        private var rews1:Array;
        private var rews2:Array;
        private var _boxCfg:Object;
        private var _itemCfg:Object;

        public function DBQBFBResultCtrl()
        {
            return;
        }// end function

        override protected function initialize() : void
        {
            super.initialize();
            this.list1.renderHandler = new Handler(this.itemHandler);
            this.list2.renderHandler = new Handler(this.itemHandler2);
            closeBtn.addEventListener(MouseEvent.CLICK, this.onClose);
            this.btn.addEventListener(MouseEvent.CLICK, this.exitHandler);
            return;
        }// end function

        protected function exitHandler(event:MouseEvent) : void
        {
            ModelProxy.change("zone", "exitInstance", null);
            this.close();
            return;
        }// end function

        protected function onClose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        private function getLayer(param1:int) : int
        {
            var _loc_2:int = 0;
            switch(param1)
            {
                case 13100:
                {
                    _loc_2 = 1;
                    break;
                }
                case 13101:
                {
                    _loc_2 = 2;
                    break;
                }
                case 13102:
                {
                    _loc_2 = 3;
                    break;
                }
                case 13103:
                {
                    _loc_2 = 4;
                    break;
                }
                case 13104:
                {
                    _loc_2 = 5;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public function show(param1:Object) : void
        {
            var _loc_2:* = param1[4];
            var _loc_3:* = param1[2];
            var _loc_4:* = int(param1[1]) + int(param1[0]);
            var _loc_5:* = this.getLayer(param1[3]);
            this.jftxt.text = _loc_3 + "";
            this.killtxt.text = _loc_4 + "";
            this.layertxt.text = _loc_5 + "";
            if (_loc_2 > 0)
            {
                this.con2.visible = true;
                this.noranktxt.visible = false;
                this.addRews2(_loc_2);
            }
            else
            {
                this.con2.visible = false;
                this.noranktxt.visible = true;
            }
            this.addRews1(_loc_3);
            this.visible = true;
            x = (GlobalLayer.instance.root.stageWidth - width) / 2;
            y = (GlobalLayer.instance.root.stageHeight - height) / 2 - 100;
            return;
        }// end function

        private function addRews2(param1:int) : void
        {
            var _loc_4:int = 0;
            this.rews2 = new Array();
            var _loc_2:* = this._rews;
            var _loc_3:* = _loc_2.split("&");
            if (_loc_3.length == 2)
            {
                _loc_3 = _loc_3[1].split("/");
                _loc_4 = int(_loc_3[(param1 - 1)]);
                this.rews2 = ItemUilt.getBoxArr(_loc_4);
            }
            this.list2.repeatX = this.rews2.length;
            this.list2.array = this.rews2;
            return;
        }// end function

        private function addRews1(param1:int) : void
        {
            var _loc_4:int = 0;
            this.rews1 = new Array();
            var _loc_2:* = this._rews;
            var _loc_3:* = _loc_2.split("&");
            if (_loc_3.length == 2)
            {
                _loc_3 = _loc_3[0].split("/");
                _loc_4 = 0;
                if (param1 > 3000)
                {
                    _loc_4 = _loc_3[0];
                }
                else if (param1 < 3000 && param1 >= 2000)
                {
                    _loc_4 = _loc_3[0];
                }
                else if (param1 < 2000 && param1 >= 1000)
                {
                    _loc_4 = _loc_3[1];
                }
                else if (param1 < 1000 && param1 >= 500)
                {
                    _loc_4 = _loc_3[2];
                }
                else if (param1 < 500 && param1 >= 100)
                {
                    _loc_4 = _loc_3[3];
                }
                else if (param1 < 100)
                {
                    _loc_4 = _loc_3[4];
                }
                this.rews1 = ItemUilt.getBoxArr(int(_loc_4));
            }
            this.list1.repeatX = this.rews1.length;
            this.list1.array = this.rews1;
            return;
        }// end function

        private function itemHandler2(param1:Component, param2:int) : void
        {
            if (param2 < list2.length)
            {
                (param1 as FlashItem).data = list2.array[param2];
            }
            return;
        }// end function

        private function itemHandler(param1:Component, param2:int) : void
        {
            if (param2 < list1.length)
            {
                (param1 as FlashItem).data = list1.array[param2];
            }
            return;
        }// end function

        public function close() : void
        {
            visible = false;
            this.list1.array = [];
            this.list2.array = [];
            return;
        }// end function

    }
}
